<template>
  <el-dialog title="业务日志" :visible.sync="showInfo" class="info-dialog" width="80%">
    <div class="time-main">
      <div class="time-day" v-for="(item,index) in timeList" :key="item.day">
        <div class="title-day">
          <div class="time-left" :class="{'time-first':index===0}">
            <span>{{item.day}}</span>
          </div>
        </div>
        <div class="title-time" v-for="day in item.list" :key="day.optTime">
          <div class="time-left" :class="{'bg-blue':day.userType===1}">
            <span>{{day.optTime}}</span>
          </div>
          <div class="time-right">
            <span>{{day.userName}}</span>
            <span>[{{day.userType===1?'供方':'采方'}}]</span>
            <span>{{day.content}}</span>
          </div>
        </div>
      </div>
      <div class="title-end"></div>
    </div>
    <span slot="footer" class="dialog-footer"></span>
  </el-dialog>
</template>
<script>
  import qs from 'qs';
  export default {
    props:['url','formData'],
    data() {
      return {
        showInfo:false,
        timeList:[],
      }
    },
    created() {
    },
    methods: {
      notice(){
        this.timeList=[];
        this.axios.post(this.url,qs.stringify(this.formData))
        .then((response)=>{
          if(response.data.success){
            response.data.resultMap.result.forEach(item=>{
              if(!this.timeList.some(val=>{return val.day===item.optDate})){
                  this.timeList.push({
                    day:item.optDate,
                    list:[item]
                  }
              );
              }else{
                this.timeList[this.timeList.findIndex(val=>{return val.day===item.optDate})].list.push(item);
              }
            })
          }
        })
        .catch((error)=>{
          console.log(error);
        });
      },
      toggleDiolag(){
        this.showInfo=!this.showInfo;
        if(this.showInfo){
          this.notice();
        }
      }
    }
  }

</script>
<style>
.info-dialog .el-dialog__body{
  padding:0 20px;
}
.time-day .title-time{
  overflow: hidden;
}
.time-left{
  width: 120px;
  text-align: right;
  border-right:1px solid #dadada;
  padding-right: 20px;
  margin-right: 20px;
  box-sizing: border-box;
}
.time-first{
  border:0;
  top:7px;
}
.time-left,.time-right{
  float: left;
  position: relative;
  height: 40px;
  line-height: 40px;
}
.title-day{
  overflow: hidden;
  color: #ef7c29;
  font-size: 16px;
  font-weight: bold;
}
.title-day .time-left:after{
  border: solid transparent;
  content: ' ';
  height: 20px;
  right: -12px;   
  top:9px; 
  position: absolute;
  width: 20px;
  border-radius: 20px;
  background: #fff;
  border: 2px solid #ef7c29;
} 
.title-time .time-left:after{
  content: ' ';
  height: 10px;
  right: -6px;
  top: 14px;
  position: absolute;
  width: 10px;
  border-radius: 10px;
  background: #ef7c29;
  border: 1px solid #ef7c29;
} 
.title-time .bg-blue.time-left:after{
  background: #409EFF;
  border: 1px solid #409EFF;
} 
.title-end{
  width: 120px;
  text-align: right;
  border-right:1px solid #dadada;
  padding-right: 20px;
  margin-right: 20px;
  box-sizing: border-box;
  height: 30px;
  position: relative;
}

.title-end:after, .title-end:before {
  border: solid transparent;
  content: ' ';
  height: 0;
  right: -11px;    
  position: absolute;
  width: 0;
} 
.title-end:after {
  border-width: 10px;
  border-top-color: #dadada;
  top: 20px;
}
</style>
